//
//  Global.h
//  omni
//
//  Created by Phuong Dinh Le on 1/25/13.
//  Copyright (c) 2013 StarPound. All rights reserved.
//

#import <Foundation/Foundation.h>

//////////////////////////////////////////////////
#pragma mark - Thread maro definition
#define THREAD_TIMEOUT 5.0f


//////////////////////////////////////////////////
typedef enum
{
    ThreadRun = 0,
    ThreadPause,
    ThreadFilter,
    ThreadStop
} ThreadStatus;

typedef enum ScreenName
{
    ScreenNameNone = 0,
    ScreenNameHomeController,
    ScreenNameTransactionBookController,
    ScreenNameLoanController,
    ScreenNameDebtController,
    ScreenNameHuiSummaryController,
    ScreenNameChartController,
    ScreenNameSettingViewController,
} ScreenName;

typedef enum
{
    BarButtonSave,
    BarButtonClose,
    BarButtonUpdate,
    BarButtonDone,
    BarButtonBadge,
    BarButtonBack,
    BarButtonMenu
}BarButton;

#define MENU_ITEM_COUNT ScreenNameSettingViewController

#define HEI_CELL_DEFAULT 50
#define HEI_CELL_MENU 60
#define HEI_SECTION 50

#define PADDING 12

//////////////////////////////////////////////////
#pragma mark - Device macro
#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_IPHONE ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPhone" ] )
#define IS_IPOD   ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPod touch" ] )
#define IS_IPHONE_5 ( IS_IPHONE && IS_WIDESCREEN )
#define IS_IPAD ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define IS_PORTRAIT ( UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]) )
#define DEVICE_ORIENTATION [[UIApplication sharedApplication] statusBarOrientation]
#define IS_PHONE ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

#define __SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_70  SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(iOS_7_0)

#define iOS_7_0 @"7.0"
#define iOS_6_0 @"6.0"


//////////////////////////////////////////////////
#pragma mark - General parameters

//////////////////////////////////////////////////

#define LOG_LEVEL_OFF     0
#define LOG_LEVEL_ERROR   1
#define LOG_LEVEL_WARN    2
#define LOG_LEVEL_INFO    3
#define LOG_LEVEL_DEBUG   4
#define LOG_LEVEL_ALL     9999

#define __LOG_LEVEL__   LOG_LEVEL_INFO

extern NSString const *logLevels[];
void NSLogWithLevel(NSUInteger logLevel, NSString *format, ...);


